<%--
  Created by IntelliJ IDEA.
  User: wk
  Date: 2020/5/9
  Time: 12:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>持明法州 后台大布局 - Layui</title>
    <link rel="stylesheet" href="./layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">layui 后台布局</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item"><a href="">控制台</a></li>
            <li class="layui-nav-item"><a href="">商品管理</a></li>
            <li class="layui-nav-item"><a href="">用户</a></li>
            <li class="layui-nav-item">
                <a href="javascript:;">其它系统</a>
                <dl class="layui-nav-child">
                    <dd><a href="">邮件管理</a></dd>
                    <dd><a href="">消息管理</a></dd>
                    <dd><a href="">授权管理</a></dd>
                </dl>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                    贤心
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="">退了</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black" >
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="menu_nav" id="menu_nav">
                <%--<li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">所有商品</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;">列表一</a></dd>
                        <dd><a href="javascript:;">列表二</a></dd>
                        <dd><a href="javascript:;">列表三</a></dd>
                        <dd><a href="">超链接</a></dd>
                    </dl>
                </li>--%>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <div class="layui-tab" lay-filter="menuTab" lay-allowClose="true" >
            <ul class="layui-tab-title">
                <li class="layui-this">欢迎页</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">欢迎使用</div>
            </div>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 底部固定区域
    </div>
</div>
<script src="./layui/layui.js"></script>
<script src="js/jquery-1.12.4.js"></script>
<script src="js/vue.min.js"></script>
<script>
    //JavaScript代码区域
    var element;
    var table;
    layui.use(['element','table'], function(){
        element = layui.element;

    });

    //打开选项卡
    function toOpenTabs(title,url,id){
        console.log(title,url,id)
        if($("li[lay-id='"+id+"']").length==0){
            element.tabAdd('menuTab', {
                title: title
                ,content:  '<iframe src="${pageContext.request.contextPath}'+url+'" width="100%" height="100%"></iframe>' //支持传入html
                ,id: id
            });
        }


        element.tabChange('menuTab',id)
    }


    $(function () {
        $.ajax({
            url:"${pageContext.request.contextPath}/menu/findAll",
            type:"POST",
            success:function (data) {
                var content = "";
                $.each(data,function (index,element) {
                    content+=" <li class=\"layui-nav-item layui-nav-itemed\">\n" +
                        "                    <a class=\"\" href=\"javascript:;\">"+element.menuName+"</a>";
                    $.each(element.cmfzMenuList,function (index1,element1) {
                        content+="<dl class=\"layui-nav-child\">\n" +
                            "                        <dd><a href=\"javascript:" +
                            "toOpenTabs('"+element1.menuName+"','"+element1.menuUrl+"',"+element1.menuId+");\">"+element1.menuName+"</a>";
                        /*content+=element1.menuName;
                        content+="</a></dd></dl>"*/
                        content+="</dd></dl>"
                    })
                    // $.each(element.cmfzMenuList,function (index1,element1) {
                    //     content+="<dl class=\"layui-nav-child\">\n" +
                    //         "                        <dd><a href=\"javascript:;\">"+element1.menuName+"</a></dd>";
                    //     content+="</dl>"
                    // })
                    // content+="</li>"
                })
                $("#menu_nav").html(content);
                layui.use('element', function(){
                    var element = layui.element;
                    element.render('nav', 'menu_nav');
                });
            }
        })
    })


</script>
</body>
</html>
